# a数组的规律是，
# 11，前一个数字1是 1个1
# 21，前个数字11是 2个1
# 1211, 前一个数字21是 1个2,1个1
# a = [1, 11, 21, 1211, 111221]
ans = []
pre, curr = "1", ""
for i in range(30):
    start = nxt = 0
    n = len(pre)
    while start < n:
        while nxt < n and pre[start] == pre[nxt]: nxt += 1
        curr += str(nxt-start) + pre[start]
        start = nxt
    pre, curr = curr, ""
ans = len(pre)
print(ans) # 5808